import {history, post, message, get} from '@/utils/utils'

const home = {
  namespaced: true,
  state: {
    tradeSummary: {},
    agentInfo: {
      agentStatus: '1'
    }
  },

  mutations: {
    save(state, { field, payload }) {
      state[field] = { ...state[field], ...payload }
    }
  },

  actions: {
    getTradeSummary({ commit }) {
      get({api: '',
        success: (data) => {
          commit('save', {field: 'tradeSummary', payload: data})
        }})
    },

    getAgentInfo({commit, dispatch}) {
      get({
        api: '/agt/agentinfo/getAgentInfo',
        success: ({data}) => {
          commit('save', {field: 'agentInfo', payload: data})
        }})
    }
  }
}

export default home
